package com.phrp.controller;

import com.phrp.entity.Notice;
import com.phrp.entity.vo.PageData;
import com.phrp.entity.vo.SearchNoticeDataVO;
import com.phrp.entity.vo.UpdateDataVO;
import com.phrp.service.NoticeService;
import com.phrp.util.returnResult.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ssc
 * @since 2024-05-01
 */
@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * 新增公告
     *
     * @param noticeData
     * @return
     */
    @PostMapping(value = "addNotice")
    public ResponseResult addNotice(@RequestBody Notice noticeData) {
        return noticeService.addNotice(noticeData);
    }

    /**
     * 根据条件搜索内容
     *
     * @param searchData
     * @return
     */
    @PostMapping(value = "searchBySearchData")
    public ResponseResult<PageData<LinkedList<Notice>>> searchBySearchData(@RequestBody SearchNoticeDataVO searchData) {
        return noticeService.searchBySearchData(searchData);
    }

    /**
     * 修改公告状态
     *
     * @return
     */
    @PostMapping(value = "updateStatus")
    public ResponseResult updateStatus(@RequestBody UpdateDataVO data) {
        return noticeService.updateStatus(data);
    }

    /**
     * 删除公告
     *
     * @param ids
     * @return
     */
    @PostMapping(value = "deleteNotice")
    public ResponseResult deleteNotice(@RequestBody LinkedList<String> ids) {
        return noticeService.deleteNotice(ids);
    }

    /**
     * 编辑
     * @param notice
     * @return
     */
    @PostMapping(value = "edit")
    public ResponseResult edit(@RequestBody Notice notice){
        return noticeService.edit(notice);
    }

}
